package cn.senwill.order_service.util;

import com.google.gson.*;
import com.google.gson.reflect.TypeToken;
import lombok.experimental.UtilityClass;
import java.util.*;

@UtilityClass
public class JsonUtil {

    /**
     * Json字符串转Map
     * @param json
     * @return
     */
    public static Map<String, Object> json2map(String json) {
        Map<String, Object> res = null;
        try {
            Gson gson = new Gson();
            res = gson.fromJson(json, new TypeToken<Map<String, Object>>() {
            }.getType());
        } catch (JsonSyntaxException e) {
        }
        return res;
    }

}
